﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Configuration;

namespace BingZi.HY.Core.Config
{
    /// <summary>
    /// 配置信息读取
    /// </summary>
    public class AppConfig
    {


        #region "读取配置信息基础函数"
        /// <summary>
        /// 读取配置信息
        /// </summary>
        /// <param name="key">配置名</param>
        /// <returns>返回配置值</returns>
        public static string GetApp(string key)
        {
            return GetApp(key, string.Empty);
        }
        /// <summary>
        /// 读取配置信息
        /// </summary>
        /// <param name="key">配置名</param>
        /// <param name="defaultValue">默认值</param>
        /// <returns>返回配置值</returns>
        public static string GetApp(string key, string defaultValue)
        {
            key = WebConfigurationManager.AppSettings[key];
            if (!string.IsNullOrEmpty(key)) return key;
            return defaultValue;
        }
        /// <summary>
        /// 读取配置信息
        /// </summary>
        /// <param name="key">配置名</param>
        /// <param name="defaultValue">默认值</param>
        /// <returns>返回配置值</returns>
        public static int GetAppInt(string key, int defaultValue)
        {
            int result = 0;
            if (int.TryParse(GetApp(key), out result) && result != 0) return result;
            return defaultValue;
        }
        #endregion

 



    }
}
